package com.nulgame.learning.rmi.launcher;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Calendar;

import com.nulgame.learning.rmi.service.CalendarService;

/**
 * Hello world!
 *
 */
public class Application 
{
    public static void main( String[] args )
    {
    	if(args.length == 1){
    		System.out.println( "Concecting to !" + args[0]);
    		try {
				Registry registry = LocateRegistry.getRegistry(args[0], 2525);
				Object o = registry.lookup("BasicCalendarService");
				if(o instanceof CalendarService){
					System.out.println( "Operation success");
					Calendar calendar = ((CalendarService) o).getDate();
					System.out.print("Current time : " + calendar.toString());
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
    	}
        
    }
}
